﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;

namespace sccf
{
    public class LoginModel
    {
        static SqlConnection connection = new SqlConnection(Vars.connectionString);

        public static string login(string usuario, string contraseña)
        {
            connection.Open();
            SqlParameter User = new SqlParameter("@usuario", usuario);
            SqlParameter Contraseña = new SqlParameter("@password", contraseña);

            SqlCommand cmd = new SqlCommand("Login", connection);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.Add(User);
            cmd.Parameters.Add(Contraseña);

            SqlDataReader reader = cmd.ExecuteReader();
            string tipousuario = "";
            while (reader.Read())
            {
                 tipousuario = reader[0].ToString();
            }
            connection.Close();
            if (tipousuario.CompareTo("")==0)
            {
                return "";
            }
            else
                return tipousuario;
        }

    }
}